package im.starchat.chat.utils;

import android.app.Activity;

import java.util.Stack;

public class ActivityManager {

    private static ActivityManager mInstance;
    private Stack<Activity> mActivities = new Stack<Activity>();

    public static ActivityManager getInstance() {
        if (mInstance == null) {
            synchronized (ActivityManager.class) {
                if (mInstance == null)
                    mInstance = new ActivityManager();
            }
        }
        return mInstance;
    }

    public void close() {
        for (Activity act : mActivities) {
            try {
                act.finish();
            } catch (Exception e) {

            }
        }
        mActivities.clear();
    }

    public void addActivity(Activity act) {
        mActivities.add(act);
    }

    public void removeActivity(Activity act) {
        mActivities.remove(act);
    }

}
